#include <stdio.h>
#include <stdlib.h>
typedef struct ListNode {
	int val;
	struct ListNode *next;
} ListNode;

ListNode *createList(int N) {
	ListNode *head = NULL;
	ListNode *tail = NULL;
	for (int i = 0; i < N; i++) {
		int num;
		scanf("%d", &num);
		ListNode *newNode = (ListNode *)malloc(sizeof(ListNode));
		newNode->val = num;
		newNode->next = NULL;
		if (head == NULL) {
			head = newNode;
			tail = newNode;
		}
		else {
			tail->next = newNode;
			tail = newNode;
		}
	}
	return head;
}

void findMaxMin(ListNode *head) {
	if (head == NULL) {
		return;
	}
	int maxVal = head->val;
	int minVal = head->val;
	int pos1 = 1;
	int pos2 = 1;
	int curPos = 1;
	ListNode *cur = head;
	while (cur != NULL) {
		if (cur->val > maxVal) {
			maxVal = cur->val;
			pos1 = curPos;
		}
		if (cur->val < minVal) {
			minVal = cur->val;
			pos2 = curPos;
		}
		cur = cur->next;
		curPos++;
	}
	printf("max=%d,pos1=%d\n", maxVal, pos1);
	printf("min=%d,pos2=%d\n", minVal, pos2);
}

int main() {
	int N;
	scanf("%d", &N);
	ListNode *head = createList(N);
	findMaxMin(head);
	return 0;
}

